package com.hangzhou.welbeing.welbeinginstrument.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.hangzhou.welbeing.welbeinginstrument.R;
import com.hangzhou.welbeing.welbeinginstrument.inteface.OnRecyclerViewItemClickListener;

import java.util.ArrayList;
import java.util.List;

/**
 * 杭州惟君医疗科技有限公司16
 * Created by 20433 on 2018/1/30
 */

public class KyushuAdapter extends RecyclerView.Adapter<KyushuAdapter.ViewHolder> implements View.OnClickListener {
    private OnRecyclerViewItemClickListener mOnItemClickListener = null;
    private Context mcontent;
    private List<String> mlistdate = new ArrayList();

    public KyushuAdapter(Context paramContext, List<String> paramList) {
        this.mcontent = paramContext;
        this.mlistdate.addAll(paramList);
    }

    public int getItemCount() {
        if (this.mlistdate.size() >= 9) {
            return 9;
        }
        return this.mlistdate.size();
    }

    public void onBindViewHolder(ViewHolder paramViewHolder, final int paramInt) {
        Glide.with(mcontent).load( "http://oop.welbeing.cn/Public/Uploads/"+mlistdate.get(paramInt)).placeholder(R.mipmap.phon_editing).error(R.mipmap.phon_editing).crossFade().into(paramViewHolder.iv_image);
    }

    public void onClick(View paramView) {
        if (this.mOnItemClickListener != null) {
            this.mOnItemClickListener.onItemClick(paramView);
        }
    }

    public ViewHolder onCreateViewHolder(ViewGroup paramViewGroup, int paramInt) {
        View view = View.inflate(paramViewGroup.getContext(), R.layout.item_kyushu_recyclerview, null);
        ViewHolder viewHolder = new ViewHolder(view);
        view.setOnClickListener(this);
        return viewHolder;
    }

    public void setOnItemClickListener(OnRecyclerViewItemClickListener paramOnRecyclerViewItemClickListener) {
        this.mOnItemClickListener = paramOnRecyclerViewItemClickListener;
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        private ImageView iv_image;
        public ViewHolder(View paramView) {
            super(paramView);
           iv_image = (ImageView) paramView.findViewById(R.id.item_kyushu_recyclerview_iv_image);
        }
    }
}
